/* 
 * File:   BoundingVolumeHierarchy.h
 * Author: brady
 *
 * Created on August 27, 2011, 5:38 PM
 */

#ifndef BOUNDINGVOLUMEHIERARCHY_H
#define	BOUNDINGVOLUMEHIERARCHY_H
#include <vector>
#include <dto/IntersectionResult.h>
#include <shapes/Shape.h>
#include <acceleration/BVHNode.h>

using namespace std;

class BoundingVolumeHierarchy : public IntersectionStructure {
public:
    BoundingVolumeHierarchy();
    BoundingVolumeHierarchy(const BoundingVolumeHierarchy& orig);
    virtual ~BoundingVolumeHierarchy();
    void addShape(Shape* shape);
    void finalize();
    IntersectionResult getFirstIntersection(IntersectionParams& ip);
    vector<IntersectionResult> getAllIntersections(IntersectionParams& ip);
    IntersectionResult getAnyIntersection(IntersectionParams& ip);
    BoundingBox getBoundingBox(){return rootNode != NULL? rootNode->getBoundingBox() : BoundingBox::inverseBox();}
    vector<Shape*> getBoundingBoxIntersections(const BoundingBox& box);
private:
    BVHNode* rootNode;
    vector<Shape*> shapes;


};

#endif	/* BOUNDINGVOLUMEHIERARCHY_H */

